home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
26
/
3
/
DISK2631.ZIP
/
EXAMP1.ZIP
/
UMEX262.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-05-18
|
2KB
|
62 lines
'User's Manual Example, Page 262.
CLS
DEFINT a-z 'integer variables are smaller and faster
$COM 1024
OPEN "COM1: 1200,N,8,1" AS #1 LEN = 1024
echo = 1
WHILE (1) 'loop forever
WHILE NOT INSTAT 'as long as no key has been pressed
IF LOC(1) > 0 THEN
stuff$ = INPUT$(LOC(1),#1) 'read incoming characters
PRINT stuff$; 'no carriage returns
'unless sent by transmitter
If already THEN PRINT #3, stuff$; 'save to disk file
END IF
WEND
WHILE INSTAT 'while there are characters at the keyboard
myinput$ = INKEY$ 'get them
IF myinput$ = CHR$(20) THEN GOSUB ReadDiskFile '^T
IF myinput$ = CHR$(18) THEN GOSUB WriteDiskFile '^R
IF myinput$ = CHR$(3) THEN CLOSE : END '^C
IF myinput$ = CHR$(5) THEN echo = ABS(echo-1):myinput$ = "" '^T
PRINT #1, myinput$; 'send typed characters
IF echo THEN PRINT myinput$; 'display them--maybe unnecessary
WEND
WEND 'check for more incoming characters
ReadDiskFile:
'a subroutine to read a disk file and transmit it
LINE INPUT "Name of the disk file: ";f$
OPEN "r", 2, f$, 1024
FIELD #2, 1024 AS disk$
r& = LOC(2)
rec = r&\1024
FOR i = 1 to rec
GET 2,i
PRINT #1, disk$;
NEXT i
IF r& MOD 1024 <> 0 THEN
GET 2, rec+1
PRINT #1, LEFT$(disk$,r& MOD 1024 );
END IF
CLOSE 2
myinput$ = ""
RETURN
WriteDiskFile:
'subroutine to write received information to disk file
'or stop that process
myinput$ = ""
IF already THEN
already = 0
CLOSE 3
RETURN
END IF
already = 1
LINE INPUT "Output file name: ";f$
OPEN f$ FOR APPEND AS #3
RETURN